<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./jquery.js"></script>
</head>
<body>
<div id="dv">11</div>

</body>
<script>
    //resolve 解决，成功
    //reject 拒绝，失败
    let promise = new Promise(function (resolve,reject) {
        //异步代码
        $.ajax({
            url:"./data/json_demo.json",
            dataType:"json",
            success(json){
                resolve(json)
            },
            error(err){
                reject(err)
            }
        })
    });
    let promise2 = new Promise(function (resolve,reject) {
        //异步代码
        $.ajax({
            url:"https://api.apiopen.top/musicBroadcasting",
            dataType:"json",
            success(json){
                resolve(json)
            },
            error(err){
                reject(err)
            }
        })
    });

    // promise.then(function (json) {
    //     console.log('成功了',JSON.stringify(json))
    // },function (err) {
    //     console.log('失败了',err)
    // })

    Promise.all([
        promise,promise2
    ]).then((arr)=>{
        console.log('chenggongle');
        let [res1,res2] = arr;
        console.log(JSON.stringify(res1));
        console.log(JSON.stringify(res2))
    },(err)=>{
        console.log('shibaile',err)
    })
</script>

</html>